new Vue({
	el: "#app",
	data: {
		imgUrl: "https://app.meijiangzi.com/static/mini_",
		ImgBaseUrl: "https://app.meijiangzi.com/static/",
		date: "",
		style: !0,
		ishow: !1,
		mall: [],
		ticket_array: "",
		ticket_id: 0,
		telNum: "",
		totalCost: 0,
		order_sn: "",
		mallID: "",
		start: "",
		currentdate: "",
		isDisabled: !1,
		referee_realname: "",
		discount: "",
		ticket_name: "",
		isPhone: !0,
		wetchartNum: "",
		ticket_mark: !1,
		collected: !0,
		appointment_price: 0,
		end_time: "",
		openid: "",
		orderType:"mjz-proj"
	},
	methods: {
		getData: function() {
			var t = this;
			wx.showLoading({
				title: "加载中",
				mask: !0
			}), this.$http.post(baseUrl + "/api/project/getDetail", {
			  guid: this.mallID,
			  userId: localStorage.getItem("userId")
			}).then(function(e) {
				wx.hideLoading();
				var a = e.data;
				if (!a.success) return wx.hideLoading(), wx.showToast({
					title: a.description,
					icon: "none",
					duration: 2e3,
					mask: !0
				}), !1;
			  t.mall = a.data, t.appointment_price = a.data.appPrice, t.totalCost = a.data.appPrice;
			}).catch(function(t) {
				wx.hideLoading(), wx.showToast({
					title: "网络错误，请检查网络",
					icon: "none",
					duration: 2e3,
					mask: !0
				});
			});
		},
		getInfoData: function() {
			var t = this;
			wx.showLoading({
				title: "加载中",
				mask: !0
			}), setTimeout(function() {
			  t.$http.post(baseUrl + "/user/api/queryUserInfo", {}).then(function(e) {
					var a = e.data;
				wx.hideLoading(), a.success ? (t.telNum = a.data.refererMobile) : wx.showToast({
						title: a.description,
						icon: "none",
						duration: 2e3,
						mask: !0
					});
				}).catch(function(t) {
					wx.hideLoading(), wx.showToast({
						title: "网络错误，请稍后重试",
						icon: "none",
						duration: 2e3,
						mask: !0
					});
				});
			}, 200);
		},
		bindDateChange: function(t) {
			this.style = !1, this.date = t.target.value;
		},
		call: function() {
		  wx.showToast({
			title: "筹备中，敬请期待",
			icon: "none",
			duration: 2e3,
			mask: !0
		  });
		},
		focusInput: function() {
			if (/^[1][2,3,4,5,6,7,8][0-9]{9}$/.test(this.telNum)) return !1;
			wx.showToast({
				title: "请输入正确的手机号",
				icon: "none",
				duration: 2e3,
				mask: !0
			});
		},
		submitBooking: function() {
			return wx.getStorageSync("open_id") ? this.date == "请选择预约时间" ? (wx.showToast({
				title: "请填写预约日期",
				icon: "none",
				duration: 2e3,
				mask: !0
			}), !1) : this.totalCost < 0 ? (wx.showToast({
				title: "支付金额必须大于0",
				icon: "none",
				duration: 2e3,
				mask: !0
			}), !1) : (wx.showLoading({
				title: "加载中",
				mask: !0
			}), void (parseFloat(this.totalCost) <= 0 ? this.conmit("1") : this.conmit("2"))) : (wx.showToast({
				title: "请先登录",
				icon: "none",
				duration: 2e3,
				mask: !0
			}), !1);
		},
		conmit: function(t) {
			var e = this;
		  this.$http.post(baseUrl + "order/project/create", {
			projectGuid: this.mallID,
			appTime: this.date,
			refererMobile: this.telNum,
				ticket_id: this.ticket_id,
			remark: this.wetchartNum
			}).then(function(a) {
				wx.hideLoading();
				var i = a.data;
			  if (i.success) e.order_sn = i.data, e.pay();
				else {
					wx.showToast({
						title: i.description,
						icon: "none",
						duration: 2e3,
						mask: !0
					});
				}
			}).catch(function(t) {
				wx.hideLoading(), wx.showToast({
					title: "网络错误，请检查网络",
					icon: "none",
					duration: 2e3,
					mask: !0
				});
			});
		},
		pay: function () {
			var t = this;
			wx.showLoading({title:"支付中..."});
			this.$http.post(baseUrl+"order/pay/appWx",{
				orderNo:this.order_sn,
				orderType: this.orderType
			}).then(function(e){
				wx.hideLoading();
				var r = e.data;
				if(!r.success){
					 wx.showToast({
						title: r.description,
						icon: "none",
						duration: 2e3,
						mask: !0
					});
				}else{
					plus.webview.create(r.data, 'proj_pay_url', {additionalHttpHeaders:{Referer:'https://app.meijiangzi.com/'}});
					Jump.to(page.pay.result, 'orderNo='+t.order_sn+'&orderType='+t.orderType);
					// window.location.href=r.data;
				}
			});
		},
		getNowFormatDate: function() {
			var t = new Date().getFullYear() - 0, e = new Date().getMonth() - 0 + 1, a = new Date().getDate() - 0, i = new Date().getFullYear() - 0, s = new Date().getMonth() - 0 + 3, n = new Date().getDate() - 0;
			e = e > 10 ? e : "0" + e, a = a > 10 ? a : "0" + a, s > 12 && (i += 1, s -= 12), 
			s = s > 10 ? s : "0" + s, n = n > 10 ? n : "0" + n, this.currentdate = t + "-" + e + "-" + a, 
			this.end_time = i + "-" + s + "-" + n;
		}
		
	},
	created: function(){
		this.openid=localStorage.getItem("open_id");
		this.style = !0, this.mallID = URLParam.get("id"), this.discount = "", this.getNowFormatDate(), 
		wx.getStorageSync("user_data").referee_phone ? (this.isPhone = !0, this.telNum = wx.getStorageSync("user_data").referee_phone) : this.isPhone = !1, 
		this.date = "请选择预约时间", this.getNowFormatDate(), this.style = !0, this.ticket_array = "", 
		this.currentIndex = "", wx.getStorageSync("user_data").referee_phone ? (this.isPhone = !0, 
		this.telNum = wx.getStorageSync("user_data").referee_phone) : (this.isPhone = !1, 
		this.telNum = ""), this.getData(), this.getInfoData();
	}
});